/************************************************************************/
/* @file            gxCustomType.h                                      */
/* @brief           Custom Types                                        */
/* @version         2013.11.15 johnxguo created                         */
/************************************************************************/

#ifndef __GX_CUSTOM_TYPE_H_INCLUDED__
#define __GX_CUSTOM_TYPE_H_INCLUDED__

#include "gxRef.h"

namespace gx
{

namespace base
{

typedef struct _GxTLV
{
    u32 uType;
    u32 uLength;
    u8* pVal;
}GxTLV;

typedef struct _GxGUID
{
    u32 d1;
    u16 d2;
    u16 d3;
    u8  d4[8];
}GxGUID;

template<class T>
class CGxCustomPtr : public IGxRef
{
public:
    CGxCustomPtr(T* pT):m_uCount(0)
    {
        m_pT = pT;
    }
    ~CGxCustomPtr()
    {
        if (m_pT)
        {
            delete m_pT;
        }
    }
    bool GetPtr(T** pT)
    {
        if (!pT)
        {
            return false;
        }
        *pT = m_pT;
        return true;
    }

private:
    DECLARE_REF_IMPL()
    CGxMutex m_mutex;
    u32      m_uCount;
    T*       m_pT;
};

}//end namespace base
}//end namespace gx

#endif